package com.prinxchengshan.reportbase.Utils;
import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoDestinationManager;
import com.sap.conn.jco.JCoException;
import java.util.logging.Logger;

public class JCoDestinationBuilder {
    public static JCoDestination destination = null;

    //private static final Logger logger = LogUtils.getPlatformLogger();
    public static JCoDestination build() throws JCoException {
        if (null == destination) {
            synchronized (JCoDestinationBuilder.class) {
                try {
                    if (null == destination)
                        destination = JCoDestinationManager.getDestination("/src/main/resources/CONNECT_SAP_CONFIG");
                    destination.ping();
                    //logger.info("Connect to SAP successfully......");
                } catch (JCoException e) {
                    e.printStackTrace();
                    //logger.error("Connect to SAP failed, error msg: " + e.toString());
                }
            }
        }
        //logger.info(String.valueOf(destination.getAttributes()));
        return destination;

    }


    public static JCoDestination build2() throws JCoException {


                try {
                    destination = null;
                    destination = JCoDestinationManager.getDestination("/src/main/resources/CONNECT_SAP_CONFIG");
                    destination.ping();
                    System.out.println(destination.hashCode());
                    //logger.info("Connect to SAP successfully......");
                } catch (JCoException e) {
                    e.printStackTrace();
                    //logger.error("Connect to SAP failed, error msg: " + e.toString());
                }


        return destination;

    }
}
